import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa';
// https://vitejs.dev/config/
export default defineConfig({
  server:{
    port: 9009,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:9009/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
   
  },
  plugins: [vue(), VitePWA({
    registerType: 'autoUpdate',
    injectRegister: false,
    strategies: 'injectManifest',
    srcDir: 'public',
    filename: 'sw.js',
    pwaAssets: {
      disabled: false,
      config: true,
    },

    manifest: {
      name: 'chat hub',
      short_name: 'chat hub',
      description: 'my first pwa demo',
      theme_color: '#4FC3F7',
    },

    // manifest: false,
    injectManifest: {
      injectionPoint: undefined,
    },


    workbox: {
      globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
      cleanupOutdatedCaches: true,
      clientsClaim: true,
    },

    devOptions: {
      enabled: true,
      navigateFallback: 'index.html',
      suppressWarnings: true,
      // type: 'module',
    },
  }),

  ],


})
